<template>
  <HomePanel title="新鲜好物" sub-title="新鲜出炉 品质靠谱" ref="target">
    <template #right>
      <XtxMore></XtxMore>
    </template>
    <ul class="goods-list" v-if="home.new.length === 0">
      <li v-for="i in 4" :key="i">
        <XtxSkeleton :width="306" :height="406" bg="#ccc" />
      </li>
    </ul>
    <ul class="goods-list" v-else>
      <li v-for="item in home.new" :key="item.id">
        <router-link :to="`/product/${item.id}`">
          <img :src="item.picture" alt="" />
          <p class="name">{{ item.name }}</p>
          <p class="price">&yen;{{ item.price }}</p>
        </router-link>
      </li>
    </ul>
  </HomePanel>
</template>

<script setup lang="ts">
import HomePanel from './home-panel.vue'
import { useObserver } from '@/hooks/index'
import { useStore } from '@/store'
const { home } = useStore()
const target = useObserver(home.findHomeNew)
</script>

<style scoped lang="scss">

.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding-top: 12px;
      text-align: center;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }
    .price {
      color: $priceColor;
    }
  }
}
</style>
